package com.hackintosh.prototype.pattern.graph;

import java.util.HashMap;
import java.util.Map;

/**
 * @description：原型管理器
 * @author：twislyn
 * @date：Created in 2021/05/06
 * @modified By：
 * @version: 1.0
 */
public class ProtoTypeManager {
    private Map<String, Shape> hashMap = new HashMap<>();

    public ProtoTypeManager() {
        hashMap.put("Circle", new Circle());
        hashMap.put("Square", new Square());
    }

    public void addShape(String key, Shape obj) {
        hashMap.put(key, obj);
    }

    public Shape getShape(String key) {
        Shape shape = hashMap.get(key);
        return (Shape) shape.clone();
    }
}
